home *** CD-ROM | disk | FTP | other *** search
- /* Parses test form */
-
- options results
-
- say "Content-Type: text/html"
- say ""
-
- getvar REQUEST_METHOD
- method = result
-
- getvar CONTENT_TYPE
- type = result
-
- getvar CONTENT_LENGTH
- length = result
-
- getvar QUERY_STRING
- query = result
-
- /* used on GET form queries */
- if length(query) > 0 then do
- /* go through the query string extracting name, value pairs */
- do forever while length(query) > 0
- parse var query name '=' value '&'
- value = plus_to_space(unescape_url(value))
- echo "<LI>name is " || name || ", value is " || value
- /* advances query to the next name=value pair */
- spot = index(query,"&")
- if (spot ~= 0) then query = substr(query,index(query,"&")+1)
- else query = ""
- end
- end
-
- say "<UL>"
- say "<LI> method is " || method
- say "<LI> type is " || type
- say "<LI> length is " || length
- say "<LI> query is " || query
-
- /* used on POST queries */
- word = getword("")
- do forever while word ~ = ""
- parse var word name '=' value
- say "<LI>name is " || name
- say "value is " || value
- word = getword("")
- end
-
- say "</ul>"
- exit
-
- /* used in POST queries, gets a name=value pair from stdin */
- getword : procedure
- retval = ""
- do forever while (eof(stdin) = 0)
- ch = readch(stdin,1)
- if ch = -1 then leav e
- if ch = '&' then leave
- retval = retval || ch
- end
- return unescape_url(plus_to_space(retval))
-
- /* Converts the "+" in the url to spaces */
- plus_to_space : procedure
- ARG url
- return translate(url, " ", "+")
-
- /* change %xx to the ascii equivalent - eg %20 is a space */
- unescape_url : procedure
- ARG url
- retval = ""
- do i = 1 to length(url)
- chr = substr(url,i,1)
- if chr = '%' then do
- chr = substr(url,i+1,2);
- newchr = x2c(chr)
- retval = retval || newchr
- i = i + 2
- end
- else retval = retval || chr
- end
- return retval
-